<template>
  <!-- 技术参数维护修改-->
  <el-dialog
    :title="title"
    center
    :visible.sync="openState"
    width="1024px"
    :close-on-click-modal="false"
    :before-close="handleClose"
  >
    <el-form ref="form" :model="form" :rules="rules" label-width="110px">
      <!--技术参数维护修改-->

      <el-row>
        <el-col :span="12">
          <el-form-item label="系统号" prop="sysFlg">
            <el-input v-model="form.sysFlg" placeholder="系统号" :disabled="true" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="内部机构号" prop="orgNo">
            <el-input v-model="form.orgNo" placeholder="内部机构号" :disabled="true" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="内部机构名称" prop="orgname">
            <el-input v-model="form.orgname" placeholder="内部机构名称" :disabled="true" />
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="12">
          <el-form-item label="参数代码" prop="paraCode">
            <el-input v-model="form.paraCode" placeholder="参数代码" :disabled="true" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="参数名称" prop="paraName">
            <el-input v-model="form.paraName" placeholder="参数名称" :disabled="true" />
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="12">
          <el-form-item label="参数值" prop="paraValue">
            <el-input v-model="form.paraValue" placeholder="参数值" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="参数描述" prop="paraDesc">
            <el-input v-model="form.paraDesc" placeholder="参数描述" />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="submitForm">提 交</el-button>
    </div>
  </el-dialog>
</template>
<script>
import { technolParamMaintainDetail, techParaUpdate } from "@/api/cnaps/bizMng/paraMng.js";
import { listPageMixin } from "@/libs/listPageMixin";

export default {
  name: "techParaDialog",
  mixins: [listPageMixin],
  components: {},
  data() {
    return {
      title: "",
      // 是否显示弹出层
      openState: false,
      // 字段可编辑控制

      //数据字典
      searchFormDictList: [],
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        sysFlg: [{ required: true, message: "系统号必填，最大长度为4", trigger: "blur", max: 4 }],
        orgNo: [{ required: true, message: "请输入内部机构号", trigger: "blur" }],
        paraCode: [{ required: true, message: "请输入参数代码", trigger: "blur" }],
        paraName: [{ required: true, message: "请输入参数名称", trigger: "blur" }],
        paraValue: [{ required: true, message: "请输入参数值", trigger: "blur" }],
        paraDesc: [{ required: true, message: "请输入参数描述", trigger: "blur" }],
      },
      opButtonList: () => {
        return [];
      },
    };
  },
  mounted() {},
  methods: {
    // 表单重置
    reset() {
      this.resetForm("form");
      this.$set(this, "form", {});
    },
    // 关闭回掉
    handleClose(done) {
      this.$confirm("确认关闭？")
        .then((_) => {
          this.reset();
          done();
        })
        .catch((_) => {});
    },
    show(row) {
      this.form = row;
      this.title = "技术参数维护修改";
      this.openState = true;

      this.technolParamMaintainDetail(row);
    },

    technolParamMaintainDetail: function (row) {
      technolParamMaintainDetail(row).then((response) => {
        this.showData(response);
      });
    },
    showData: function (response) {
      this.form = response.result;
    },

    /** TODO提交按钮 */
    submitForm: function () {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          this.submit();
        }
      });
    },

    submit() {
      techParaUpdate(this.form).then((res) => {
        if (res.code === "S") {
          this.msgSuccess("提交成功");
          this.cancel();
        }
      });
    },

    cancel() {
      this.openState = false;
      this.reset();
      this.$emit("editComplete", true);
    },
  },
};
</script>
<style>
.label-header-msg {
  font-weight: bold;
}

.form-card {
  margin-bottom: 10px;
}
</style>
